package team.seekers.hula.common.entity.enums.question;

import com.baomidou.mybatisplus.core.enums.IEnum;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum AnswerOrderEnum implements IEnum<Integer> {

    DEFAULT(0, "默认"),
    NEW(1, "最新"),
    ME(2, "我的");

    private int type;

    private String name;

    AnswerOrderEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }

    @Override
    public Integer getValue() {
        return this.type;
    }

    public static AnswerOrderEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }

    public static AnswerOrderEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equals(name)).findFirst().orElse(null);
    }

}

